package com.haojin.exer1;

public class CheckAccount extends Account {

	private double overdraft;

	public CheckAccount(int id, double balance, double annuallnterestRate, double overdraft) {
		super(id, balance, annuallnterestRate);
		this.overdraft = overdraft;
	}

	public void withdraw(double amount) {// 取款方法
		if (amount <= getBalance()) {
			super.withdraw(amount);
			System.out.println("可透支额为：" + overdraft);
		} else if (overdraft >= amount - getBalance()) {// 透支额度足够消费
			overdraft -= (amount - getBalance());
			setBalance(0);
			System.out.println("取款成功，余额为："+getBalance());
			System.out.println("可透支限额剩余：" + overdraft);
		}else{
			System.out.println("超过可透支限额，取款失败。");
			System.out.println("可透支限额剩余：" + overdraft);
		}
	}
}
